package com.ruoyi.merchant.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.merchant.domain.dto.UpdateShopInfoDTO;
import com.ruoyi.merchant.domain.vo.ShopStatusVO;
import com.ruoyi.merchant.service.IMerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 商家门店Controller
 */
@RestController
@RequestMapping("/merchant/shop")
public class MerchantShopController extends BaseController {

    @Autowired
    private IMerchantService merchantShopService;

    /**
     * 修改门店信息
     */
    @PutMapping("/update-info")
    public AjaxResult updateInfo(@Validated @RequestBody UpdateShopInfoDTO updateDTO) {
        int rows = merchantShopService.updateShopInfo(updateDTO);
        return rows > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
    }

    /**
     * 查询门店营业状态
     */
    @GetMapping("/status")
    public AjaxResult getStatus() {
        ShopStatusVO statusVO = merchantShopService.getShopStatus();
        return AjaxResult.success("查询成功", statusVO);
    }
}
